home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 19
/
Mac Magazin and MacEasy Magazine CD - Issue 19.iso
/
Online
/
LineShare 3.3.1
/
LineShare Scripts
/
Generic Fax1&ARA
< prev
next >
Wrap
Text File
|
1994-02-10
|
7KB
|
344 lines
! Version 2.1
!
!$ Requires: Class 1 fax modem hardware handshaking cable.
!$ Supports: fax and ARA software in the server mode.
!$ Fax Receiving: if Adaptive Answering is implemented
!$ Use: Class 1 for Fax, ARA/LineShare for ARA.
!$ Read: your modem manual to modify the "AT" strings.
!$ See: the Generic Scripts Guide for details.
^2 Speaker On: = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
^3 Speaker Volume: = Enum("Low"="1","Medium"="2","High"="3") "2"
^4 Answer On: = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
^5 Adaptive Answering: = Text ""
^6 AT for Normal mode: = Text ""
^7 AT for HW Handshake: = Text ""
^8 AT for SW Handshake: = Text ""
! ------------------------------------------
! Resetting the modem:
! ------------------------------------------
@Hangup
SetTries 2
Flush
HsReset 0,0,17,19,0,0
!
! Try to catch the "OK" answer, use the Escape seq and DTR transitions
! to enter the command mode
!
@Label 1
matchclr
matchstr 1 2 "OK\r\n"
write "ATH0&FV1\r"
matchread 20
ChrDelay 1
Write "+++"
ChrDelay 0
DtrClear
LBreak
DtrSet
!
DecTries
IfTries 0 1
!
! OSErr -6019 "Modem error - the modem is not responding"
!
exit -6019
@Label 2
write "AT+FCLASS=0\r"
Jsr 100
ifStr 5 3 ""
write "AT^5\48\r"
Jsr 100
@Label 3
exit 0
! ------------------------------------------
! Receiving incoming calls
! ------------------------------------------
@ANSWER
SetVar A ""
IfStr A 50 "^6^7^8"
!
! Set the modem preferred speed first
!
SerReset 19200,0,8,1
Jsr 80
@Label 10
!
! Set the common options
Jsr 70
!
! Set the communication options:
! • Normal connection, report connection speed (for ARA)
! • HW flow control (for ARA, Fax should not use a handshake on receiving)
!
Write "AT^7^6\r"
Jsr 100
!
! Set Fax mode & adaptive answering (if necessary)
!
ifStr 5 15 ""
!
Write "AT+FCLASS=1\r"
Jsr 100
Write "AT^5\49\r"
Jsr 100
Write "AT+FCLASS=0\r"
Jsr 100
!
! Fetch the tube after ^4 rings
! Switch to numeric answers (for fax software)
!
Write "ATS0=^4V0\r"
Jsr 110
!
! Everything is ready - let's sit and wait for a call
! We'll wait for 2 minutes, then reinitiate the modem
!
Note "Waiting for a fax or ARA call…"
MatchClr
MatchStr 02 40 "47\r"
MatchStr 03 40 "10\r"
MatchStr 04 41 "48\r"
MatchStr 05 41 "11\r"
MatchStr 06 42 "49\r"
MatchStr 07 43 "50\r"
MatchStr 08 43 "12\r"
MatchStr 09 44 "51\r"
MatchStr 10 44 "13\r"
MatchStr 11 45 "52\r"
MatchStr 15 31 "33\r"
MatchStr 16 13 "2\r"
MatchStr 17 30 "1\r"
MatchStr 18 12 "3\r"
MatchStr 19 12 "8\r"
MatchStr 20 12 "7\r"
@Label 11
Matchread 1200
@Label 12
Note "Tuning again…"
Write "ATV1"
Jsr 100
Jump 10
@Label 13
Note "Ring…"
Jump 11
!
! No adaptive answering -> work in verbal mode (more reliable)
!
@Label 15
Write "ATS0=^4\r"
Jsr 100
!
Note "Waiting for an ARA call…"
MatchStr 1 20 "\r\nCARRIER "
MatchStr 2 20 "\r\nCONNECT "
MatchStr 3 17 "\r\nRING\r\n"
MatchStr 4 10 "\r\nNO "
@Label 16
Matchread 1200
jump 10
@Label 17
Note "Ring…"
jump 16
!
! Data connection has been established (we read "CARRIER")
! Put the "CONNECT" back to the buffer and attach the "Data" subPort
! if it was an incoming call, put the "RING" before the "CONNECT"
!
@Label 20
QueueInput "\r\nCARRIER "
ifOriginate 21
QueueInput "\r\nRING\r\n"
@Label 21
Attach "ARA" (DTR,Escape,TimeLimit=0)
!
! Fax connection has been established (we read "FAX")
! Put the +FCON back to the buffer,
! if it was an incoming call, put the "RING" before the "+FCON"
! Attach the "Fax" subPort
!
@Label 30
QueueInput "1\r"
ifOriginate 32
@Label 31
QueueInput "2\r2\r"
@Label 32
Attach "Fax" (Reset(2400),IdleLimit=30)
!
! Converting numeric responses into the verbal
!
@Label 40
QueueInput "2400\r\n"
Jump 20
@Label 41
QueueInput "4800\r\n"
Jump 20
@Label 42
QueueInput "7200\r\n"
Jump 20
@Label 43
QueueInput "9600\r\n"
Jump 20
@Label 44
QueueInput "12000\r\n"
Jump 20
@Label 45
QueueInput "14400\r\n"
Jump 20
@Label 50
Note "Suspended"
Say "Press the Options… button to enter the AT-strings for your modem!"
Pause 1200
Jump 50
! ------------------------------------------
! Originating a call through the "ARA" subport
! ------------------------------------------
@ORIGINATE "ARA"
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
!
Jsr 70
!
! Set the Data mode:
! • Normal connection, report connection speed
! • HW Handshake
!
Write "AT^6^7\r"
Jsr 100
!
! Prepare to receive all error result codes, dial the number
!
Jsr 90
MatchStr 1 20 "\r\nCARRIER "
MatchStr 2 20 "\r\nCONNECT "
MatchRead 1000
Write "\r"
Exit -6019
! ------------------------------------------
! Originating a call through the "Fax" subPort
! ------------------------------------------
@ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
!
! Set the "Fax" speed
!
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
!
Jsr 70
!
! Set the Fax mode (Xon/Xoff)
Write "AT&S0^8+FCLASS=1\r"
Jsr 100
!
! Now emit all commands that the application has sent to that port,
! except "FCLASS", etc
!
EmitClear "FCLASS","V","X","E"
Jsr 60
Write "ATV0\r"
Jsr 110
!
! Prepare to receive all error result codes, dial the number
!
MatchClr
MatchStr 01 30 "1\r"
MatchStr 13 93 "3\r"
MatchStr 14 94 "8\r"
MatchStr 15 92 "7\r"
Write "ATD^1\r"
HsReset *
MatchRead 1000
Write "\r"
Exit -6019
!
! This section emits all modem commands sent from the client application
! For each set of commands the "OK" answer is awaited
!
@Label 60
EmitStart
@Label 61
EmitCommand 62
Jsr 100
Jump 61
@Label 62
return
!
! This section initiates the modem before ANSWER and ORIGINATEs:
! extended responses + connect at the highest rate + speaker control +
! reset on Dtr drop + DCD valid
! Verbal responses mode, no echo
!
@Label 70
Write "ATX4M^2L^3&D2&C1V1E0\r"
Jsr 100
return
!
! This section syncronize the modem after the serial port speed switching
!
@Label 80
ChrDelay 1
Write "AT\r"
ChrDelay 0
Jsr 100
return
!
! Prepare to receive error result codes, send the dialing command and
! set the user's handshake mode
!
@Label 90
MatchClr
MatchStr 2 91 "NO DIALTONE\r\n"
MatchStr 3 92 "BUSY\r\n"
MatchStr 4 93 "NO CARRIER\r\n"
MatchStr 5 94 "NO ANSWER\r\n"
Write "ATD^1\r"
HsReset *
return
@Label 91
exit -6020
@Label 92
exit -6022
@Label 93
exit -6021
@Label 94
exit -6023
!
! Processing the AT command:
! OK -> proceed
! ERROR or TimeOut ->exit -6019
! It can be called AFTER the "Write" command, since LineShare buffers input
!
@Label 100
MatchClr
MatchStr 1 103 "\r\nOK\r\n"
MatchStr 2 102 "\r\nERROR\r\n"
@Label 101
MatchRead 20
@Label 102
Exit -6019
@Label 103
return
@Label 110
MatchClr
MatchStr 1 103 "0\r"
MatchStr 2 102 "4\r"
Jump 101